using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using TeamCommunitySolution.Extensions.ModuleProxies;
using TeamCommunitySolution.Models;

namespace TeamCommunitySolution.Controllers
{
    public class SearchController : Controller
    {
        // 
        // AJAX: /Search/SearchForUsername
        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public ActionResult SearchForUsername(string username)
        {
            UserModel user = new BaseModuleProxy().FindUserByUsername(username);

            return Json(user);
        }

        // 
        // AJAX: /Search/SearchForNickname
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult SearchForNickname(string nick)
        {
            UserModel user = new BaseModuleProxy().FindUserByNickName(nick);

            bool output = false;

            if(!string.IsNullOrEmpty(user.NickName))
            {
                output = true;
            }

            return Json(output);
        }

    }
}